package kokonut.shop.product;

import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

@PersistenceCapable
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public class Product {

    @Persistent
    private String name;
    @Persistent
    private int ref;
    @Persistent
    private ProductType type;
    @Persistent
    private float price;
    @Persistent
    private String imageURL;

    public Product() {
    }

    public Product(String name, int ref, float price, ProductType type, String imageURL) {
        this.name = name;
        this.ref = ref;
        this.price = price;
        this.type = type;
        this.imageURL = imageURL;
    }

    public String getImageURL() {
        if (imageURL != null) {
            return imageURL;
        } else {
            return "";
        }
    }

    public void setImageURL(String imageURL) {
        this.imageURL = imageURL;
    }

    public String getType() {
        return type.name();
    }

    public void setType(ProductType type) {
        this.type = type;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        if (name != null) {
            return name;
        } else {
            return "";
        }
    }

    public int getRef() {
        return ref;
    }

    public void setRef(int ref) {
        this.ref = ref;
    }
}
